// pages/detailClue/detailClue.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    clue: {
      album: "",
      confirm: 1,
      content: "",
      createTime: "",
      discoveryTime: "",
      id: "",
      latitude: 0,
      longitude: 0,
      place: '',
      phone:'12345678901'
    },
    
    // detailContent:'我在钱江湾生活区见到了他',
    markers:[]

  },
  preView(e){
    // console.log(e.currentTarget.dataset.src)
    wx.previewImage({
      urls: this.data.clue.album, //需要预览的图片http链接列表，注意是数组
      current: '', // 当前显示图片的http链接，默认是第一个
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  


  },
  getCLueById(clueId){
    wx.showLoading({
      title: '数据加载中',
    })
    
   
    wx.request({
      url: app.globalData.Baseip+':8882/clue/getClueDetailsById?clueId='+clueId,
      header: {
        Authorization:app.globalData.header
       },
      method:'GET',
      success:res=>{
        console.log(res)
        var data = res.data.data;
        console.log(data)
        var markList = []
        var mark = {
        }
        mark.id = 1,
        mark.width = 40,
        mark.height = 40,
        mark.iconPath='../../images/loc2.png',
        mark.latitude=data.latitude,
        mark.longitude=data.longitude,
        markList.push(mark)
        this.setData({
          clue:data,
          markers:markList
        })
      
        wx.hideLoading({
          success: (res) => {},
        })
      },
      fail:function(err){
        console.log(err)
        wx.hideLoading({
          success: (res) => {},
        })
      }
    })

  },
  pass(e){
    //通过 添加到上面的列表
    console.log(e.currentTarget.dataset.clueid)
    wx.request({
      url: app.globalData.Baseip+':8882/clue/confirmClue?clueId='+this.data.clue.id,
     
      method:'POST',
      header: {
        Authorization:app.globalData.header
      },
      success:res=>{
       
     
        wx.navigateBack({
          delta: 1,
        })
        wx.hideLoading({
          success: (res) => {},
        })
      
      },
      fail:function(err){
        console.log(err)
        wx.hideLoading({
          success: (res) => {},
        })
      }
    })
  },

  noPass(e){
    //删除线索
    console.log(e.currentTarget.dataset.clueid)
    wx.request({
      
      url: app.globalData.Baseip+':8882/clue/repulseClue?clueId='+this.data.clue.id,
     
      method:'POST',
      header: {
        Authorization:app.globalData.header
      },
      success:res=>{
       
      
        wx.navigateBack({
          delta: 1,
        })
        wx.hideLoading({
          success: (res) => {},
        })
      
      },
      fail:function(err){
        console.log(err)
        wx.hideLoading({
          success: (res) => {},
        })
      }
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //根据id获取线索
    this.getCLueById(options.clueId)
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})